<?php
class QPriviledge
{
  
	static $_table = 'priviledges';
	
	static function search($p_strCountry)
	{
		$strQuery	=	'SELECT `id` , `group`, `function`, `admin`, `inventory`, `marketing`, `buying`  FROM `'
						.$p_strCountry.'_'.self::$_table.'`';
      
		$db 		=	Zend_Registry::get('db');
		$resultValue = $db->fetchAll($strQuery);
		$db->closeConnection();
		return $resultValue;
	}
	
	static function checkPriviledge($userinGroup, $group, $function, $p_strCountry)
	{
	 	$strQuery	=	'SELECT `id` , `group`, `function`, `admin`, `inventory`, `marketing`, `buying`  FROM `'
						.$p_strCountry.'_'.self::$_table 
   						."` WHERE `group`='".$group . "' AND `function` ='" . $function ."'"; 
		$db 		=	Zend_Registry::get('db');
		$arrData 	=	$db->fetchAll($strQuery);
		$db->closeConnection();
		return $arrData;
	}	
	
	public static function insert($p_arrParams, $p_Country)
	{
		$db	= Zend_Registry::get('db');
		$resultValue = $db->insert($p_Country ."_". self::$_table , $p_arrParams);
		$db->closeConnection();
		return $resultValue;
	}
	
	public static function update($p_arrParams, $p_Country)
	{
		$db	= Zend_Registry::get('db');
		$resultValue = $db->update($p_Country ."_". self::$_table, $p_arrParams, "id=" . "'" .$p_arrParams["id"] . "'");
		$db->closeConnection();
		return $resultValue;
	}
}
?>